<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->id();
            $table->unsignedInteger('role')->default(0)->comment('角色:0用户，1经理，2员工');
            $table->tinyInteger('verify')->default(0)->comment('房东是否通过了审核：0没有，1通过');
            $table->string('username',50)->nullable()->comment('账号');
            $table->string('truename',50)->nullable()->default('未知')->comment('真实姓名');
            $table->string('password',255)->nullable()->comment('密码');
            $table->string('email',50)->nullable()->comment('邮箱');
            $table->string('phone',15)->default('')->comment('手机号码');
            $table->string('nickName')->default('')->comment('小程序昵称');
            $table->string('avatarUrl')->default('')->comment('小程序头像');
            $table->string('country')->default('')->comment('国家');
            $table->string('province')->default('')->comment('省份');
            $table->string('city')->default('')->comment('城市');
            $table->unsignedTinyInteger('gender')->default(0)->comment('性别 0 未知，1男性 ，2女性，');
            $table->string('unionid')->default('')->comment('平台唯一识别');
            $table->string('openid')->default('')->comment('小程序openid');


            $table->char('last_ip',15)->default('')->comment('登录IP');
            $table->unsignedInteger('invite_num')->default(0)->comment('推荐码');

            $table->tinyInteger('working')->default(0)->comment('0空闲中1繁忙中');
            // 软删除 生成一字段  deleted_at 字段
            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('users');
    }
}
